1. Field of the Invention
The present invention relates to a storing method and processing device thereof, and more particularly, to a storing method and processing device thereof capable of safely storing captured image data.
2. Description of the Prior Art
Monitoring equipment is very popular in recent years, a video recording system such as a camera, an event data recorder or wearable mobile camera can be seen everywhere for monitoring or recording. Since a monitoring equipment usually needs to record image for a long time, and store captured images into a storage device which usually has limited capacity, the monitoring equipment needs to have the functionality of loop recording. For example, if the storage device can only 5-hour-long video and audio file, when the captured image data is longer than 5 hour, oldest image data is deleted for saving new image data.
Current multi-media formats are mainly MPEG-4 Part 14 (MP4) or QuickTime (QT). Formats MP4 or QT can be normal and fragmented. Normal format stores media content in one media content container (such as MDAT) related to a document, and stores metadata in one metadata container (such as MOOV) of one document. Conventionally, the media content container includes practically media sampling, such as video and/or audio frame. Each media has itself metadata track (TRAK) in the metadata container MOOV for describing characteristics of the media content such as encoding level, bit rate, frame rate, interval. Additional container of the metadata container MOOV includes information related to characteristics of document and document content.
Please refer to FIG. 1, which is a schematic diagram of a conventional monitoring equipment performing storing when a storage format is normal storage format. As shown in FIG. 1, take a blank Secure Digital card (SD card) which is formatted as FAT32 file system as example, every 5 minutes long media data is divided as an audio and video file and it already records 5 minutes and 20 seconds long media data. The first audio and video file 11 of the monitoring equipment is completed and has 5 minutes long media content, and the second audio and video file 12 is recording and its metadata (index value) is stored in memory and is not yet written into the storage device (the audio and video file 12 is not completed and does not includes the metadata MOOV yet). Each divided audio and video file needs to have complete file header FTYP, media content MDAT and metadata MOOV for play.
However, during the recording process, since the metadata MOOV is usually written at last, if abnormal event such as power cut occurs before or during the metadata MOOV is written, the last audio and video file (e.g. audio and video file 12) cannot be played because the metadata MOOV is not written completely. Take an event data recorder as an example, power cut occurs as an accident occurs, and thus the key image finally captured may be damaged, thereby losing protection for the user.
Compared with the normal format, the fragmented storage format is commonly used in machine with less resource or machine which may occur power cut since the metadata (index value) and media content can be written alternatively and thus the fragmented-structure file has stronger error tolerance. Please refer to FIG. 2, which is a schematic diagram of a fragmented storage format. As shown in FIG. 2, the fragmented storage format is a media file format based on International Organization for Standardization (ISO). The fragmented storage format file is formed by multiple media content containers 23 (i.e. MDAT), corresponding multiple fragment metadata containers 22 (i.e. MOOF), and a basic shape only metadata container 21 (i.e. MOOV) which only roughly describes messages related to media such as definition and compression format. A movie fragment header (i.e. MFHD) 211 describe characteristics corresponding to the media fragments and includes sequence numbers of the media fragments. In the same file, the sequence numbers of the media fragments have to be arranged to increase progressively, otherwise the file is considered illegal.
The fragmented format needs to overwrite oldest fragments when the storage device is full and perform loop recording. Please refer to FIG. 3, which is a schematic diagram of the conventional fragmented format in a recording device with loop recording capability when the storage device is full. As shown in FIG. 3, at this moment, the oldest 1st fragment 31 will be overwritten by the newest N+1th fragment 32. Since sequence numbers of media fragments in the same file have to be arranged to increase progressively and the N+1th fragment and its sequence number occurs before other fragments and sequence numbers thereof which is illegal, the method disclosed by U.S. Pat. No. 7,817,903B2 needs to be applied frequently to perform file system operations (e.g. modify file link in a format of FAT32) to avoid a reversed sequence. But if power cut or equipment damage occurs during file system operations, completeness of the file is damaged.
On the other hand, in order for the user to keep important fragments to avoid interested media fragments are overwritten by the above mentioned loop recording, some monitoring equipment provides an emergency recording mechanism. For example, some monitoring equipment edits one minute long media data before and after the emergency recording mechanism is activated as an emergency image file. Assume that a user activates the emergency recording mechanism after recording 5 minutes and 20 seconds long media data in a normal format, a state of the storage device at this moment is as shown in FIG. 1. Then, please refer to FIG. 4, which is a schematic diagram of allocation of the storage device when a conventional method activating emergency recording. As shown in FIG. 4, after activating emergency recording, the system will find a allocable space 43 in the storage device and write a file header (i.e. FTYP) 431. Because media files are divided as 5 minutes long per file, last 40 seconds image content 411 (slant line region) of the media content MDAT the previous audio and video file 11 and first 20 seconds image content 421 (point region) of a media content MDAT of the current audio and video file 12 are copied to the space 43. At this moment, video recording is simultaneously performed with the emergency recording mechanism.
Finally, please refer to FIG. 5, which is a schematic diagram of allocation of the storage device after the conventional method of FIG. 4 completes emergency recording. As shown in FIG. 5, 60 seconds image content 522 (mesh region) after the emergency recording is activated is copied into the space 43, and the system calculates metadata (i.e. MOOV) 534 for the edited media data to complete the emergency image file 53. During the above procedure, the system utilizes two threads, wherein a recording thread continues loop recording and an emergency recording thread reads and copies the above metadata and media content, and the two threads persistent request storage spaces from the storage device. The conventional file division method is based on play interval of a media file, since encoding bit rates are not fixed due to complexity of different recording environments, each of the divided audio and video files 11, 12 has different sizes. Besides, the emergency recording mechanism makes storage space to be further allocated for storing the emergency recording file, thereby causing the normal recording file and the emergency recording file to be stored in discontinuous storage space, generating several fragmentations in space allocation.
In addition, steps of the conventional emergency recording are complex, and perform file editing procedures of the emergency recording mechanism while performing recording simultaneously. Under a situation of performing high definition recording or a SD card with a slow storing speed, it is a big challenge to system performance. It is very likely that the captured media data lose some frames when the system performance is not enough.
Therefore, it is very important in the industry to avoid the problems of media damages due to the unwritten index information MOOV caused by power cut and reversed sequence numbers of the fragmented storage format, and to simplify complex steps of the emergency recording to reduce consumption of the system performance and avoid discontinuous storage space which causes several fragmentations in space allocation.